<?php require_once ('../common/check.php');  //权限校验 ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>后台管理系统</title>
    <link href="images/index.css" type="text/css" rel="stylesheet"/>
    <script src="images/jquery.js"></script>
</head>
<body>
<?php require "top.php" ?>
<section>
    <?php require "left.php" ?>
    <div class="mainbox">
        <div class="note">
            <h4>文章分类列表</h4>
            <table class="news_list">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>名字</th>
                    <th>简介</th>
                    <th>是否显示</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php
                //>>1.连接数据库
                require('../common/conn.php');
                //>>2.
                $sql = "select * from category";
                $result= mysqli_query($link,$sql);
                if($result===false){ //表示执行的sql有错误sql
                    echo "错误代码: ".mysqli_errno($link)."<br/>";
                    echo "错误信息: ".mysqli_error($link)."<br/>";
                    echo "SQL语句: ".$sql;
                    exit;
                }
                $rows = mysqli_fetch_all($result,MYSQLI_ASSOC);
                foreach($rows as $row):
                    ?>
                    <tr>
                        <td><?=$row['id']?></td>
                        <td><?=$row['name']?></td>
                        <td><?=$row['intro']?></td>
                        <td><?=$row['is_show']?"是":"否"?></td>
                        <td>
                            <a href="category.php?action=edit&id=<?=$row['id']?>">修改</a>
                            <a href="category.php?action=del&id=<?=$row['id']?>">删除</a>
                        </td>
                    </tr>
                <?php endforeach;?>
                </tbody>
            </table>
        </div>
    </div>
</section>
<script>
    $(function(){
        $('dt').click(function(){
            var obj=$(this).next();
            if($(this).next().css('display')=='block'){
                obj.hide('fast');
                $(this).removeClass('on');
            }else{
                obj.show('fast');
                $(this).addClass('on');
            }
        });
    });
</script>
</body>
</html>